package com.dai.zhenfujin.visitingcard.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.animation.AlphaAnimation;
import android.widget.RelativeLayout;

import com.dai.zhenfujin.MainActivity;
import com.dai.zhenfujin.R;
import com.dai.zhenfujin.WelcomeActivity;
import com.dai.zhenfujin.utils.SPUtils;
import com.hyphenate.chat.EMClient;
import com.jaeger.library.StatusBarUtil;

public class LaunchActivity extends Activity {
    private RelativeLayout llRootView;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launch);
        StatusBarUtil.setTransparent(this);
        llRootView = findViewById(R.id.ll_root_view);
        AlphaAnimation animation = new AlphaAnimation(0.3f, 1.0f);
        animation.setDuration(1500);
        llRootView.startAnimation(animation);
        EMClient.getInstance().chatManager().loadAllConversations();
        loadData();
    }

    protected void loadData() {
        //耗时任务，比如加载网络数据
        getCircleData();
        llRootView.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (SPUtils.getBoolean(LaunchActivity.this,"welcome")) {
                    Intent intent = new Intent(LaunchActivity.this, MainActivity.class);
                    intent.putExtra("showRed",0);
                    startActivity(intent);
                } else {
                    Intent intent = new Intent(LaunchActivity.this, WelcomeActivity.class);
                    startActivity(intent);
                }
                //结束当前的 Activity
                finish();
            }
        }, 1000);
    }

    private void getCircleData() {

    }
}
